/*
 * @Author: 噜噜雯雯 2199987619@qq.com
 * @Date: 2025-05-28 11:29:08
 * @LastEditors: 噜噜雯雯 2199987619@qq.com
 * @LastEditTime: 2025-09-28 09:58:23
 * @FilePath: \linePatrol\vue-element-plus-admin\src\api\linePatrol\index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import service from '@/axios/http'
// import { GetPlanGroupType, RoleType,ParameterListType,XunLineAreaType, EventTypeListType, AddEventType, EditEventType } from './type';
import { TableIResponse } from '@/utils/Api'
import {
  AlertHandle,
  MarDayReport,
  MarkerListType,
  AlertHistory,
  MarTreeData,
  DtuListType,
  HistoryDataType,
  RealGasType,
  DTUAttributeList,
  DetectorDetail,
  MeasureFactor,
  AlertList,
  HandleDetails
} from './type'
export class SCADAApi {
  //获取部门
  //获取部门树形结构
  async GetDtuList(params: any): Promise<TableIResponse<DtuListType[]>> {
    const result = (await service.get(`/api/scada/DTU/list`, { params })) as unknown as any
    return result
  }
  // 查询历史数据
  async GetHistoryData(params: any): Promise<TableIResponse<HistoryDataType[]>> {
    const result = (await service.get(`/api/scada/HistoryData/list`, { params })) as unknown as any
    return result
  }
  // 查询属性数据
  async GetAttributeListData(params: any): Promise<DTUAttributeList[]> {
    const result = (await service.get(`/api/scada/HistoryData/DTUAttributeList`, {
      params
    })) as unknown as any
    const { code, data } = result
    if (code == 200) {
      return data
    } else {
      return []
    }
  }
  // 查询报警历史数据
  async GetAlertHistory(params: any): Promise<TableIResponse<AlertHistory[]>> {
    const result = (await service.get(`/api/scada/HistoryData/alertList`, {
      params
    })) as unknown as any
    return result
  }
  // 查询报警列表
  async GetAlertList(params: any): Promise<TableIResponse<AlertList[]>> {
    const result = (await service.get(`/api/scada/alertLatestLog/list`, {
      params
    })) as unknown as any
    return result
  }
  // 查询报警处理列表
  async GetAlertHandleList(params: any): Promise<TableIResponse<AlertHandle[]>> {
    const result = (await service.get(`/api/scada/alertHandle/list`, { params })) as unknown as any
    return result
  }
  // 查询报警处理明细
  async GetAlertHandleDetails(params: any): Promise<HandleDetails[]> {
    const result = (await service.get(`/api/scada/alertHandleDetails/list`, {
      params
    })) as unknown as any
    const { code, data } = result
    if (code == 200) {
      return data
    } else {
      return []
    }
  }
  //删除报警处理
  async DeleteAlertHandle(uuids: string): Promise<boolean> {
    const result = (await service.delete(`/api/scada/alertHandle/${uuids}`)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //删除报警数据
  async DeleteAlertList(AlertData: AlertList): Promise<boolean> {
    const result = (await service.delete(`/api/scada/alertLatestLog/remove`, {
      data: AlertData
    })) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //新增报警处理
  async AddAlertHandle(data: AlertList): Promise<boolean> {
    const result = (await service.post('/api/scada/alertHandle', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //新增报警处理明细
  async AddHandleDetails(data: HandleDetails): Promise<boolean> {
    const result = (await service.post('/api/scada/alertHandleDetails', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  // 查询当前站点用气量
  async GetRealGas(): Promise<RealGasType[]> {
    const result = (await service.get(`/api/scada/DTU/RealTimeData`)) as unknown as any
    const { code, data } = result
    if (code == 200) {
      return data
    } else {
      return []
    }
  }
  // 查询30用气量
  async GetMonthGas(devNumber: string): Promise<any> {
    const result = (await service.get(`/api/scada/DTU/gas30DayData/${devNumber}`)) as unknown as any
    const { code, data } = result
    if (code == 200) {
      return data
    } else {
      return []
    }
  }
  // 查询站点设备联动
  async GetMarTreeData(): Promise<MarTreeData[]> {
    const result = (await service.get(`/api/scada/DTU/getMarTreeData`)) as unknown as any
    const { code, data } = result
    if (code == 200) {
      return data
    } else {
      return []
    }
  }
  //查询站点配置列表
  async GetMarkerList(): Promise<MarkerListType[]> {
    const result = (await service.get(`/api/scada/marker/list`)) as unknown as any
    const { code, data } = result
    if (code == 200) {
      return data
    } else {
      return []
    }
  }
  // 查询站点详情
  async GetMarkerDetail(uuid: string | undefined): Promise<any> {
    const result = (await service.get(`/api/scada/marker/${uuid}`)) as unknown as any
    const { code, data } = result
    if (code == 200) {
      return data
    } else {
      return []
    }
  }
  // 查询站点详情
  async Getdetectoretail(uuid: string | undefined): Promise<any> {
    const result = (await service.get(`/api/scada/detector/${uuid}`)) as unknown as any
    const { code, data } = result
    if (code == 200) {
      return data
    } else {
      return []
    }
  }
  //修改站点
  async EditMarker(data: MarkerListType): Promise<boolean> {
    const result = (await service.put('/api/scada/marker', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //添加站点
  async AddMarker(data: MarkerListType): Promise<boolean> {
    const result = (await service.post('/api/scada/marker', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //添加附加设备
  async AddDetector(data: DetectorDetail): Promise<boolean> {
    const result = (await service.post('/api/scada/detector', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //添加量测
  async AddMeasureFactor(data: MeasureFactor): Promise<boolean> {
    const result = (await service.post('/api/scada/measureFactor', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //修改量测
  async EditMeasureFactor(data: MeasureFactor): Promise<boolean> {
    const result = (await service.put('/api/scada/measureFactor', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //修改附加设备
  async EditDetector(data: DetectorDetail): Promise<boolean> {
    const result = (await service.put('/api/scada/detector', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //删除站点配置
  async DeleteMarker(uuid: string): Promise<boolean> {
    const result = (await service.delete(`/api/scada/marker/${uuid}`)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //删除附加设备
  async DeleteDetector(uuids: string): Promise<boolean> {
    const result = (await service.delete(`/api/scada/detector/${uuids}`)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //删除附加设备
  async DeleteMeasureFactor(uuids: string): Promise<boolean> {
    const result = (await service.delete(`/api/scada/measureFactor/${uuids}`)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  // 查询站点日报（ALL）
  async GetMarDayReport(params: any): Promise<MarDayReport[]> {
    const result = (await service.get(`/api/scada/dayReports/marDayReport`, {
      params
    })) as unknown as any
    const { code, data } = result
    if (code == 200) {
      return data
    } else {
      return []
    }
  }
  // 查询站点月报（ALL）
  async GetMarMonthReport(params: any): Promise<MarDayReport[]> {
    const result = (await service.get(`/api/scada/dayReports/marMonthReport`, {
      params
    })) as unknown as any
    const { code, data } = result
    if (code == 200) {
      return data
    } else {
      return []
    }
  }
}
export default new SCADAApi()
